<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>罚单打印</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
    <link rel="stylesheet" href="../js/lay-module/step-lay/step.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-body" style="padding-top: 40px;">
                    <div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto;">
                        <div carousel-item>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">罚单编号:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写罚单编号" class="layui-input" value="3416017001814648" required />
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">违法信息:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写违法信息编号或车牌号" value="湘AZH726" class="layui-input" required>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">交警姓名:</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="请填写罚单编号" class="layui-input" value="xxx" required />

                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开具单位:</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="" placeholder="请选择所属交警大队行政区划" autocomplete="off" class="layui-input" id="my-area">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button class="layui-btn" lay-submit lay-filter="formStep">
                                                &emsp;下一步&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">罚单编号:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">3416017001814648</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">违法信息:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">湘AZH726</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">交警姓名:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">xxx</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">开具单位:</label>
                                        <div class="layui-input-block">
                                            <div class="layui-form-mid layui-word-aux">xx市xxx区大队</div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-input-block">
                                            <button type="button" class="layui-btn layui-btn-primary pre">上一步</button>
                                            <button class="layui-btn" lay-submit lay-filter="formStep2">
                                                &emsp;确认打印&emsp;
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div>
                                <div style="text-align: center;margin-top: 90px;">
                                    <i class="layui-icon layui-circle"
                                       style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
                                    <div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
                                        罚单打印成功
                                    </div>
                                    <div style="font-size: 14px;color: #666;margin-top: 20px;">请前往打印机处查收结果</div>
                                </div>
                                <div style="text-align: center;margin-top: 50px;">
                                    <button class="layui-btn next">重新打印</button>
                                    <button data-method="notice" class="layui-btn layui-btn-primary to-watch">查看罚单</button>
                                    <button data-method="notice" class="layui-btn layui-btn-primary to-send">通知发送</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <hr>
                    <div style="color: #666;margin-top: 30px;margin-bottom: 40px;padding-left: 30px;">
                        <h3>说明</h3><br>
                        <h4>请按照规定流程填写打印。</h4>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use([ 'form', 'step', 'tableSelect', 'layer'], function () {
        var $ = layui.$,
            form = layui.form,
            step = layui.step,
            tableSelect = layui.tableSelect,
            layer = layui.layer;

        step.render({
            elem: '#stepForm',
            filter: 'stepForm',
            width: '100%', //设置容器宽度
            stepWidth: '750px',
            height: '500px',
            stepItems: [{
                title: '填写罚单违法信息'
            }, {
                title: '确认罚单违法信息'
            }, {
                title: '完成'
            }]
        });

        tableSelect.render({
            elem: '#my-area',	// 定义输入框input对象 必填
            checkedKey: 'id', // 表格的唯一建值，非常重要，影响到选中状态 必填
            searchKey: 'keyword',	// 搜索输入框的name值 默认keyword
            searchPlaceholder: '关键词搜索',	// 搜索输入框的提示文字 默认关键词搜索
            height: '350',  // 自定义高度
            minWidth: '350',  // 自定义宽度
            table: {	// 定义表格参数，与LAYUI的TABLE模块一致，只是无需再定义表格elem
                url: '../api/areaSelect.json',
                cols: [[
                    { type: 'radio' },
                    { field: 'id', title: '编号' },
                    { field: 'username', title: '交警大队' },
                    { field: 'addr', title: '地址' }
                ]]
            },
            done: function (elem, data) {
                // 选择完后的回调，包含2个返回值 elem:返回之前input对象；data:表格返回的选中的数据 []
                // 拿到data[]后 就按照业务需求做想做的事情啦~比如加个隐藏域放ID...
                var NEWJSON = []
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.username)
                })
                elem.val(NEWJSON.join(","))
            }
        });


        form.on('submit(formStep)', function (data) {
            step.next('#stepForm');
            return false;
        });

        form.on('submit(formStep2)', function (data) {
            step.next('#stepForm');
            return false;
        });

        $('.pre').click(function () {
            step.pre('#stepForm');
        });

        $('.next').click(function () {
            step.next('#stepForm');
        });

        var active = {
            notice: function () {
                // 示范一个公告层
                layer.open({
                    type: 1,
                    offset: '20px'
                    , title: false //不显示标题栏
                    , closeBtn: false
                    , area: '400px;'
                    , shade: 0.8
                    , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    , btn: ['关闭']
                    , btnAlign: 'c'
                    , moveType: 1 //拖拽模式，0或者1
                    , content: '<div style="padding: 10px; background-color: #393D49; color: #fff; font-weight: 300;"><img src="http://localhost:8080/file-server/fd.png" style="width: 100%; height:100%;"></div>'
                });
            }
        };
        $('.to-watch').on('click', function () {
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });
        $('.to-send').on('click', function () {
            var index = layer.open({
                title: '罚单发送',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: '../page/sender.html',
                success: function(layerdoc, index) {
                    // success会携带两个参数，分别是当前层DOM、当前层索引。
                    // 获取新开的iframe的body dom
                    var childPage = layer.getChildFrame('body', index);
                    childPage.find('#fd-pic').attr('src', 'http://localhost:8080/file-server/fd.png')
                }
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
        });
    })
</script>
</body>
</html>